package POJO;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "WISH_LIST", uniqueConstraints = {
		@UniqueConstraint(columnNames = "Wish_List_Id"),
		@UniqueConstraint(columnNames = "Wish_List_Name")
})
public class WishList {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "Wish_List_Id", unique = true)
	private int wishListId;
	
	@Column(name = "Wish_List_Name")
	private String wishListName;
	
	@Column(name = "Date_Create")
	private Date dateCreate;
	
	@Column(name = "Last_Modifier")
	private Date lastModifier;
	
	@ManyToOne()
	@JoinColumn(name = "Customer_Id")
	private Customer customer;

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "PRODUCT_DETAIL_WISH_LIST", joinColumns = {
			@JoinColumn(name = "Wish_List_Id", nullable = false, updatable = false)},
			inverseJoinColumns = { @JoinColumn(name = "Product_Detail_Id", 
												nullable = false, updatable = false)})
	private Set<ProductDetail> productDetails;
	
	public WishList() {
		super();
	}

	public WishList(String wishListName, Customer customer) {
		super();
		this.wishListName = wishListName;
		this.customer = customer;
	}

	public int getWishListId() {
		return wishListId;
	}

	public void setWishListId(int wishListId) {
		this.wishListId = wishListId;
	}

	public String getWishListName() {
		return wishListName;
	}

	public void setWishListName(String wishListName) {
		this.wishListName = wishListName;
	}

	public Date getDateCreate() {
		return dateCreate;
	}

	public void setDateCreate(Date dateCreate) {
		this.dateCreate = dateCreate;
	}

	public Date getLastModifier() {
		return lastModifier;
	}

	public void setLastModifier(Date lastModifier) {
		this.lastModifier = lastModifier;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
}
